package com.longcheer.weibo;

import com.longcheer.weibo.vo.User;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class UserManager {
    
    private Map<Long, User> mCache = new ConcurrentHashMap<Long, User>();
    
    private static UserManager instance;
    
    private UserManager() {
        
    }
    
    public static UserManager getInstance() {
        if (instance == null) {
            instance  = new UserManager();
        }
        return instance;
    }
    
    public void put(User user) {
        Long userId = user.getId();
        mCache.put(userId, user);
    }
    
    public User get(Long userId) {
        return mCache.get(userId);
    }
}
